import dayjs from "dayjs";
import {JSONFilePreset} from "lowdb/node";
import logger from "log4js";

export const isBlzTokenExpired = (expiresIn) => {

    return expiresIn === null || expiresIn === '' ? true : dayjs().isAfter(dayjs(expiresIn))
}

export const getDB = async () => {
    // 初始化数据库
    logger.getLogger('init-DB').info("init DB")
    return await JSONFilePreset('db.json', {blzHsToken: null, expiresIn: null})
}